package service

import (
	"strings"

	"gitee.com/Luna-CY/Golang-Project-Template/internal/errors"
	"gitee.com/Luna-CY/Golang-Project-Template/internal/util/pointer"
	"gitee.com/Luna-CY/Golang-Project-Template/model"
)

type SystemSmtpLogField field[model.SystemSmtpLog]

func SystemSmtpLogFieldWithCc(cc ...string) SystemSmtpLogField {
	return func(o *model.SystemSmtpLog) errors.Error {
		o.Cc = pointer.New(strings.Join(cc, ","))

		return nil
	}
}

func SystemSmtpLogFieldWithBcc(bcc ...string) SystemSmtpLogField {
	return func(o *model.SystemSmtpLog) errors.Error {
		o.Bcc = pointer.New(strings.Join(bcc, ","))

		return nil
	}
}

func SystemSmtpLogFieldWithStatus(status model.SystemSmtpLogStatus) SystemSmtpLogField {
	return func(o *model.SystemSmtpLog) errors.Error {
		o.Status = pointer.New(status)

		return nil
	}
}

func SystemSmtpLogFieldWithFailedReason(failedReason string) SystemSmtpLogField {
	return func(o *model.SystemSmtpLog) errors.Error {
		o.FailedReason = pointer.New(failedReason)

		return nil
	}
}

func SystemSmtpLogFieldWithCompleteTime(completeTime int64) SystemSmtpLogField {
	return func(o *model.SystemSmtpLog) errors.Error {
		o.CompleteTime = pointer.New(completeTime)

		return nil
	}
}
